<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"          
                template="../../template/tagedu.xhtml">


    <ui:define name="title">
        <title><h:outputText value="TAG - Visualizar Planos"/></title>
    </ui:define>
    <ui:define name="content">
        <link rel="Stylesheet" type="text/css" href="../../resources/css/main.css"></link>
        <link rel="Stylesheet" type="text/css" href="../../resources/css/plans.css"></link>
        <h:outputText styleClass="planName" value="Buscar Planos"/>
        <f:event type="preRenderComponent" listener="#{viewPlans.initPlan()}"/>
        <h:form id="viewPlanForm" styleClass="planOpt">
            <table width="950" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td valign="top" style="">
                        <h:outputLabel styleClass="planOptLabel" for="yearsList" value="Ano*: "/>
                        <h:selectOneMenu id="yearsList" styleClass="planOptSOM" value="#{viewPlans.year}" required="true" requiredMessage="Campo Obrigatório">
                            <f:selectItems value="#{viewPlans.yearList}"/>
                        </h:selectOneMenu>
                        <h:message for="yearsList" styleClass="message"/>
                    </td>
                    <td valign="top" style="">
                        <h:outputLabel styleClass="planOptLabel" for="organization" value="Organização*: "/>
                        <h:selectOneMenu id="organization" styleClass="planOptSOM" value="#{viewPlans.organizationID}" required="true" requiredMessage="Campo Obrigatório">
                            <f:selectItems value="#{viewPlans.organizationList}"/>
                        </h:selectOneMenu>
                        <h:message for="organization" styleClass="message"/>
                    </td>
                    <td valign="top" style="">
                        <h:outputLabel styleClass="planOptLabel" for="discipline" value="Disciplina*: "/>
                        <h:selectOneMenu id="discipline" styleClass="planOptSOM" value="#{viewPlans.disciplineID}" required="true" requiredMessage="Campo Obrigatório">
                            <f:selectItems value="#{viewPlans.disciplineList}"/>
                        </h:selectOneMenu>
                        <h:message for="discipline" styleClass="message"/>
                    </td>
                    <td valign="top" style="">
                        <h:commandButton value="Buscar">
                            <f:ajax execute="@form" render="@form" listener="#{viewPlans.search()}"/>
                        </h:commandButton>
                    </td>
                </tr>
            </table><BR/>
            <p:dataTable emptyMessage="Sem resultados" value="#{viewPlans.planList}" var="plan">
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Período"/>
                    </f:facet>
                    <h:outputLink value="editPlans.xhtml">
                        <f:param name="plan" value="#{plan.id}"/>
                        <h:outputText value="#{plan.season.description}"/>
                    </h:outputLink>                    
                </p:column>
                <p:column>
                    <p:commandLink value="Excluir" onclick="confirmExclusion.show()">
                        <f:setPropertyActionListener target="#{viewPlans.plan}" value="#{plan}"/>
                    </p:commandLink>
                </p:column>
            </p:dataTable>
        </h:form>
    </ui:define>

    <ui:define name="modals">
        <p:dialog modal="true" header="Excluir Plano" widgetVar="confirmExclusion" resizable="false">
            <h:form>
                <table width="100%">
                    <tbody>
                        <tr>
                            <td align="center" width="50%">
                                <p:commandButton value="OK" action="#{viewPlans.removePlan()}" update=":viewPlanForm" onclick="confirmExclusion.hide();"/>
                            </td>
                            <td align="center" width="50%">
                                <p:commandButton value="Cancelar" onclick="confirmExclusion.hide();"/>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </h:form>
        </p:dialog>
    </ui:define>
</ui:composition>